package com.cf.model;

import com.cf.code.core.CField;
import com.cf.code.core.CModel;
import com.cf.code.core.CPage;
import com.cf.code.core.FieldType;
import com.cf.crud.entity.BaseEntity;

import javax.persistence.*;
import java.util.Date;

/**
 * boot-shop-Category
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/8/16 下午 02:56
 */
@Entity
@Table(name = "category")
@CModel(pages = {
        @CPage(title = "类目列表", path = "category", templateName = "list.ftl", outPutName = "list.ftl"),
        @CPage(title = "类目", path = "category", templateName = "add.ftl", outPutName = "add.ftl"),
        @CPage(title = "类目", path = "category", templateName = "update.ftl", outPutName = "update.ftl")
})
public class Category extends BaseEntity {

    @CField(lab = "类目名字")
    private String name;

    @CField(lab = "类目名字", type = FieldType.SELECT, dataUrl = "/category/search?name=", selectKey = "name", selectValue = "id")
    @Column(name = "parentId")
    private long parentId;

    @CField(lab = "类目状态", type = FieldType.SELECT, defaultValue = "[{\"name\":\"正常\",\"value\":1},{\"name\":\"废弃\",\"value\":-1}]", selectValue = "value", selectKey = "name")
    private int status = CategoryStatus.COMMON.getStatus();

    /**
     * 创建时间
     */
    @Column(name = "addTime")
    @Temporal(TemporalType.DATE)
    private Date addTime = new Date();

    /**
     * 更新时间
     */
    @Column(name = "updateTime")
    @Temporal(TemporalType.DATE)
    private Date updateTime = new Date();


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getParentId() {
        return parentId;
    }

    public void setParentId(long parentId) {
        this.parentId = parentId;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
